package com.qzyh.esb.egsa.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qzyh.esb.egsa.entity.MainSystem;
import com.qzyh.esb.egsa.entity.Requirement;
import com.qzyh.esb.egsa.mapper.MainSystemMapper;
import com.qzyh.esb.egsa.service.IMainSystemService;
import com.qzyh.esb.egsa.utils.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * <p>
 * 主系统信息表 服务实现类
 * </p>
 *
 * @author whq
 * @since 2023-11-02
 */
@Service
public class MainSystemServiceImpl extends ServiceImpl<MainSystemMapper, MainSystem> implements IMainSystemService {

    @Autowired
    private MainSystemMapper mainSystemMapper;


    @Override
    public IPage<MainSystem> getList(IPage<MainSystem> page, String name) {
        QueryWrapper<MainSystem> wrapper = Wrappers.query();
        if (StringUtils.hasLength(name)){
            wrapper.like("name", name);
        }
        wrapper.orderByDesc("create_time");
        return mainSystemMapper.selectPage(page, wrapper);
    }

    @Override
    public ResultObject<List<MainSystem>> getMainSysList(String keywords) {
        QueryWrapper<MainSystem> wrapper = Wrappers.query();
        wrapper.select("id,name");
        wrapper.like("name",keywords);
        List<MainSystem> list = mainSystemMapper.selectList(wrapper);
        return ResultObject.success(list);
    }
}
